Skip to content

Split index.js types into index.js.flow#49470

Closed
huntie wants to merge 1 commit into
facebook:mainfrom
huntie:export-D69659837
Closed

Split index.js types into index.js.flow#49470
huntie wants to merge 1 commit into
facebook:mainfrom
huntie:export-D69659837

Conversation

@huntie
Copy link
Copy Markdown
Member

@huntie huntie commented Feb 17, 2025

Summary:
Adds a packages/react-native/index.js.flow file.

Motivation

This is on the critical path to generating TypeScript types, and a full API snapshot, from index.js.flow.

As we iterate, this new file will move to closely matching types/index.d.ts by adding type exports (missing today) — giving us an equivalent public API in both languages.

Motivation for this pattern

Having a type index file:

  • Will become the entry point for yarn build-types.
  • Enables us to bypass the module.exports pattern in index.js without a runtime breaking change.
    • This pattern is preferable because:
      • 1/ Aligns with existing manual TypeScript definitions (i.e. these are already restricted to import syntax in user code)
      • 2/ Allows doc comments on original types to propagate to IDEs/users.

Implementation notes

NOTE: This diff has no effect on compiled code at runtime, and no effect on the current manual TypeScript API of react-native. It only has an effect on Flow usage in fbsource — most of which are deep type imports today.

  • Exports are grouped and sorted identically to each pre-existing getter in index.js.

Changelog: [Internal] - Redefine root react-native type exports, affecting Flow usages only

Differential Revision: D69659837

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D69659837

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported p: Facebook Partner: Facebook Partner labels Feb 17, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D69659837

Summary:

Adds a `packages/react-native/index.js.flow` file.

**Motivation**

This is on the critical path to generating TypeScript types, and a full API snapshot, from `index.js.flow`.

As we iterate, this new file will move to closely matching `types/index.d.ts` by adding type exports (missing today) — giving us an equivalent public API in both languages.

**Motivation for this pattern**

Having a type index file:

- Will become the entry point for `yarn build-types`.
- Enables us to bypass the `module.exports` pattern in `index.js` without a runtime breaking change.
    - This pattern is preferable because:
        - 1/ Aligns with existing manual TypeScript definitions (i.e. these are **already restricted** to `import` syntax in user code)
        - 2/ Allows doc comments on original types to propagate to IDEs/users.

**Implementation notes**

NOTE: This diff has **no effect** on compiled code at runtime, and **no effect** on the current manual TypeScript API of `react-native`. It only has an effect on Flow usage in fbsource — most of which are deep type imports today.

- Exports are grouped and sorted identically to each pre-existing getter in `index.js`.

Changelog: [Internal] - Redefine root `react-native` type exports, affecting Flow usages only

Reviewed By: rubennorte

Differential Revision: D69659837
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D69659837

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 17, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in cda2d11.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @huntie in cda2d11

When will my fix make it into a release? | How to file a pick request?

@huntie huntie deleted the export-D69659837 branch April 22, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants